$(function () {
    $('#submit').click(function () {
        var EorN = $("input[name='username']").val();

        var rege = /^.{1,20}@\w{1,10}\.\w{1,5}$/;
        var type = 1;       //type 为登录方式 1为邮箱登录 2为账号登录

        if(!rege.test(EorN)){
            type = 2;
        }

        var user_pwd = $("input[name='user_pwd']").val();
        var ccap = $("input[name='ccap']").val();

        $.post(
            'login',
            {
                user_name:EorN,
                user_pwd:user_pwd,
                ccap:ccap,
                type:type
            },
            function (data) {
                alert(data.msg);
                if(data.code == 200){
                    location.href = '/index/index/index';
                }
            }
        );



    });
});